using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using LAMSDK.Security.Entities;

namespace LAMSDK.Security.Mapping
{
	public class UserInRoleMap : EntityTypeConfiguration<UserInRole>
	{
		public UserInRoleMap()
		{
			// Primary Key
			this.HasKey(t => new { t.UserId, t.RoleId });

			// Properties
			this.Property(t => t.UserId)
				.HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
				
			this.Property(t => t.RoleId)
				.HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
				
			// Table & Column Mappings
			this.ToTable("UserInRole");
			this.Property(t => t.UserId).HasColumnName("UserId");
			this.Property(t => t.RoleId).HasColumnName("RoleId");
		}
	}
}

